#include "knightsprite.h"
#include "all_gfx.h"

#define SPEED_NORMAL 5

KnightSprite::KnightSprite(u8 screen, u8 id, RpgSpritePal *palette)
        : RpgPlayableSprite(screen, id, (void *) knight_Sprite , palette)
{
}

void KnightSprite::checkInput()
{
    if (Pad.Newpress.Right)
    {
        setSpriteRight();
        setAnimMoveRight(SPEED_NORMAL);
    }

    if (Pad.Newpress.Left)
    {
        setSpriteLeft();
        setAnimMoveLeft(SPEED_NORMAL);
    }

    if (Pad.Newpress.Up)
    {
        setSpriteUp();
        setAnimMoveUp(SPEED_NORMAL);
    }

    if (Pad.Newpress.Down)
    {
        setSpriteDown();
        setAnimMoveDown(SPEED_NORMAL);
    }

    if (Pad.Held.Left)
    {
        setPosition(x() - Pad.Held.Left, y());
    }
    else if (Pad.Held.Right)
    {
        setPosition(x() + Pad.Held.Right, y());
    }
    else if (Pad.Held.Up)
    {
        setPosition(x(), y() - Pad.Held.Up);
    }
    else if (Pad.Held.Down)
    {
        setPosition(x(), y() + Pad.Held.Down);
    }
    else
    {
        setCurrentFrame(currentFrame());
    }
}
